package com.qianfeng.zhangwei.sybl.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * @说 明：
 * @项目名称：Sz1504
 * @包 名： com.qianfeng.zhangwei.sybl.adapter
 * @类 名： GuidePagerAdapter
 * @创 建人： zhangwei
 * @创建时间：2015-07-27 16:12
 * @版 本：v1.0
 * @修 改人：
 * @修改时间：
 * @修改备注：
 *
 */
public class GuidePagerAdapter extends PagerAdapter {
    private List<View> views;

    public GuidePagerAdapter(List<View> views) {
        this.views = views;
    }

    @Override
    public int getCount() {
        return views != null && views.size() > 0 ? views.size() : 0;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = views.get(position);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(views.get(position));
    }
}
